package com.atguigu.composite2;

public class Main {

	public static void main(String[] args) {
		// 创建根节点及其子节点
		Composite root = new Composite("根部");
		root.add(new Leaf("Leaf A"));
		root.add(new Leaf("Leaf B"));

		// 创建第二层节点及其子节点
		Composite branch = new Composite("Composite X");
		branch.add(new Leaf("Leaf X_A"));
		branch.add(new Leaf("Leaf X_B"));
		root.add(branch);

		// 创建第三层节点及其子节点
		Composite branch2 = new Composite("Composite XY");
		branch2.add(new Leaf("Leaf XY_A"));
		branch2.add(new Leaf("Leaf XY_B"));
		branch.add(branch2);

		// 创建第二层节点
		root.add(new Leaf("Leaf C"));

		// 打印
		root.display(2);
	}

}